package 设计模式.行为型模式.Strategy_if_else.asr;

import java.util.Arrays;
import java.util.List;

/**
 * ASR服务工厂
 */
public class ASRServiceFactory {
    private final List<ASRService> asrServices;
    
    public ASRServiceFactory() {
        // 初始化所有适配器
        this.asrServices = Arrays.asList(
            new AliyunASRAdapter(),
            new TencentASRAdapter(),
            new DefaultASRAdapter()  // 默认放在最后
        );
    }
    
    /**
     * 获取适合的ASR服务
     * @param vendorId 厂商ID
     * @return ASR服务实例
     */
    public ASRService getASRService(String vendorId) {
        return asrServices.stream()
            .filter(service -> service.supports(vendorId))
            .findFirst()
            .orElseThrow(() -> new IllegalArgumentException("不支持的ASR服务商: " + vendorId));
    }
}